// gorpc/server/service/impl/calc_service_impl.go

package service

import "errors"

type CalcServiceImpl struct{}

func (s *CalcServiceImpl) Add(a, b int) (int, error) {
	return a + b, nil
}

func (s *CalcServiceImpl) Sub(a, b int) (int, error) {
	return a - b, nil
}

func (s *CalcServiceImpl) Mul(a, b int) (int, error) {
	return a * b, nil
}

func (s *CalcServiceImpl) Div(a, b int) (int, error) {
	if b == 0 {
		return 0, errors.New("division by zero")
	}
	return a / b, nil
}

func (s *CalcServiceImpl) Mod(a, b int) (int, error) {
	if b == 0 {
		return 0, errors.New("division by zero")
	}
	return a % b, nil
}
